<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>ctrmm.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CTRMM.1"></a><a href="ctrmm.f.html#CTRMM.1">CTRMM</a>(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
<span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      COMPLEX ALPHA
      INTEGER LDA,LDB,M,N
      CHARACTER DIAG,SIDE,TRANSA,UPLO
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      COMPLEX A(LDA,*),B(LDB,*)
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CTRMM.14"></a><a href="ctrmm.f.html#CTRMM.1">CTRMM</a>  performs one of the matrix-matrix operations
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     B := alpha*op( A )*B,   or   B := alpha*B*op( A )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where  alpha  is a scalar,  B  is an m by n matrix,  A  is a unit, or
</span><span class="comment">*</span><span class="comment">  non-unit,  upper or lower triangular matrix  and  op( A )  is one  of
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     op( A ) = A   or   op( A ) = A'   or   op( A ) = conjg( A' ).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  ==========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  SIDE   - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry,  SIDE specifies whether  op( A ) multiplies B from
</span><span class="comment">*</span><span class="comment">           the left or right as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              SIDE = 'L' or 'l'   B := alpha*op( A )*B.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              SIDE = 'R' or 'r'   B := alpha*B*op( A ).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  UPLO   - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, UPLO specifies whether the matrix A is an upper or
</span><span class="comment">*</span><span class="comment">           lower triangular matrix as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              UPLO = 'U' or 'u'   A is an upper triangular matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              UPLO = 'L' or 'l'   A is a lower triangular matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TRANSA - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, TRANSA specifies the form of op( A ) to be used in
</span><span class="comment">*</span><span class="comment">           the matrix multiplication as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              TRANSA = 'N' or 'n'   op( A ) = A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              TRANSA = 'T' or 't'   op( A ) = A'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              TRANSA = 'C' or 'c'   op( A ) = conjg( A' ).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  DIAG   - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, DIAG specifies whether or not A is unit triangular
</span><span class="comment">*</span><span class="comment">           as follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              DIAG = 'U' or 'u'   A is assumed to be unit triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              DIAG = 'N' or 'n'   A is not assumed to be unit
</span><span class="comment">*</span><span class="comment">                                  triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  M      - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, M specifies the number of rows of B. M must be at
</span><span class="comment">*</span><span class="comment">           least zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N      - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, N specifies the number of columns of B.  N must be
</span><span class="comment">*</span><span class="comment">           at least zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ALPHA  - COMPLEX         .
</span><span class="comment">*</span><span class="comment">           On entry,  ALPHA specifies the scalar  alpha. When  alpha is
</span><span class="comment">*</span><span class="comment">           zero then  A is not referenced and  B need not be set before
</span><span class="comment">*</span><span class="comment">           entry.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A      - COMPLEX          array of DIMENSION ( LDA, k ), where k is m
</span><span class="comment">*</span><span class="comment">           when  SIDE = 'L' or 'l'  and is  n  when  SIDE = 'R' or 'r'.
</span><span class="comment">*</span><span class="comment">           Before entry  with  UPLO = 'U' or 'u',  the  leading  k by k
</span><span class="comment">*</span><span class="comment">           upper triangular part of the array  A must contain the upper
</span><span class="comment">*</span><span class="comment">           triangular matrix  and the strictly lower triangular part of
</span><span class="comment">*</span><span class="comment">           A is not referenced.
</span><span class="comment">*</span><span class="comment">           Before entry  with  UPLO = 'L' or 'l',  the  leading  k by k
</span><span class="comment">*</span><span class="comment">           lower triangular part of the array  A must contain the lower
</span><span class="comment">*</span><span class="comment">           triangular matrix  and the strictly upper triangular part of
</span><span class="comment">*</span><span class="comment">           A is not referenced.
</span><span class="comment">*</span><span class="comment">           Note that when  DIAG = 'U' or 'u',  the diagonal elements of
</span><span class="comment">*</span><span class="comment">           A  are not referenced either,  but are assumed to be  unity.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA    - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, LDA specifies the first dimension of A as declared
</span><span class="comment">*</span><span class="comment">           in the calling (sub) program.  When  SIDE = 'L' or 'l'  then
</span><span class="comment">*</span><span class="comment">           LDA  must be at least  max( 1, m ),  when  SIDE = 'R' or 'r'
</span><span class="comment">*</span><span class="comment">           then LDA must be at least max( 1, n ).
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B      - COMPLEX          array of DIMENSION ( LDB, n ).
</span><span class="comment">*</span><span class="comment">           Before entry,  the leading  m by n part of the array  B must
</span><span class="comment">*</span><span class="comment">           contain the matrix  B,  and  on exit  is overwritten  by the
</span><span class="comment">*</span><span class="comment">           transformed matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB    - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, LDB specifies the first dimension of B as declared
</span><span class="comment">*</span><span class="comment">           in  the  calling  (sub)  program.   LDB  must  be  at  least
</span><span class="comment">*</span><span class="comment">           max( 1, m ).
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Level 3 Blas routine.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- Written on 8-February-1989.
</span><span class="comment">*</span><span class="comment">     Jack Dongarra, Argonne National Laboratory.
</span><span class="comment">*</span><span class="comment">     Iain Duff, AERE Harwell.
</span><span class="comment">*</span><span class="comment">     Jeremy Du Croz, Numerical Algorithms Group Ltd.
</span><span class="comment">*</span><span class="comment">     Sven Hammarling, Numerical Algorithms Group Ltd.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL <a name="LSAME.128"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      EXTERNAL <a name="LSAME.129"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL <a name="XERBLA.132"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC CONJG,MAX
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      COMPLEX TEMP
      INTEGER I,INFO,J,K,NROWA
      LOGICAL LSIDE,NOCONJ,NOUNIT,UPPER
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      COMPLEX ONE
      PARAMETER (ONE= (1.0E+0,0.0E+0))
      COMPLEX ZERO
      PARAMETER (ZERO= (0.0E+0,0.0E+0))
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      LSIDE = <a name="LSAME.151"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(SIDE,<span class="string">'L'</span>)
      IF (LSIDE) THEN
          NROWA = M
      ELSE
          NROWA = N
      END IF
      NOCONJ = <a name="LSAME.157"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANSA,<span class="string">'T'</span>)
      NOUNIT = <a name="LSAME.158"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(DIAG,<span class="string">'N'</span>)
      UPPER = <a name="LSAME.159"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'U'</span>)
<span class="comment">*</span><span class="comment">
</span>      INFO = 0
      IF ((.NOT.LSIDE) .AND. (.NOT.<a name="LSAME.162"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(SIDE,<span class="string">'R'</span>))) THEN
          INFO = 1
      ELSE IF ((.NOT.UPPER) .AND. (.NOT.<a name="LSAME.164"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'L'</span>))) THEN
          INFO = 2
      ELSE IF ((.NOT.<a name="LSAME.166"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANSA,<span class="string">'N'</span>)) .AND.
     +         (.NOT.<a name="LSAME.167"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANSA,<span class="string">'T'</span>)) .AND.
     +         (.NOT.<a name="LSAME.168"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANSA,<span class="string">'C'</span>))) THEN
          INFO = 3
      ELSE IF ((.NOT.<a name="LSAME.170"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(DIAG,<span class="string">'U'</span>)) .AND. (.NOT.<a name="LSAME.170"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(DIAG,<span class="string">'N'</span>))) THEN
          INFO = 4
      ELSE IF (M.LT.0) THEN
          INFO = 5
      ELSE IF (N.LT.0) THEN
          INFO = 6
      ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
          INFO = 9
      ELSE IF (LDB.LT.MAX(1,M)) THEN
          INFO = 11
      END IF
      IF (INFO.NE.0) THEN
          CALL <a name="XERBLA.182"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>(<span class="string">'<a name="CTRMM.182"></a><a href="ctrmm.f.html#CTRMM.1">CTRMM</a> '</span>,INFO)
          RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible.
</span><span class="comment">*</span><span class="comment">
</span>      IF (N.EQ.0) RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     And when  alpha.eq.zero.
</span><span class="comment">*</span><span class="comment">
</span>      IF (ALPHA.EQ.ZERO) THEN
          DO 20 J = 1,N
              DO 10 I = 1,M
                  B(I,J) = ZERO
   10         CONTINUE
   20     CONTINUE
          RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Start the operations.
</span><span class="comment">*</span><span class="comment">
</span>      IF (LSIDE) THEN
          IF (<a name="LSAME.204"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANSA,<span class="string">'N'</span>)) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Form  B := alpha*A*B.
</span><span class="comment">*</span><span class="comment">
</span>              IF (UPPER) THEN
                  DO 50 J = 1,N
                      DO 40 K = 1,M
                          IF (B(K,J).NE.ZERO) THEN
                              TEMP = ALPHA*B(K,J)
                              DO 30 I = 1,K - 1
                                  B(I,J) = B(I,J) + TEMP*A(I,K)
   30                         CONTINUE
                              IF (NOUNIT) TEMP = TEMP*A(K,K)
                              B(K,J) = TEMP
                          END IF
   40                 CONTINUE
   50             CONTINUE
              ELSE
                  DO 80 J = 1,N
                      DO 70 K = M,1,-1
                          IF (B(K,J).NE.ZERO) THEN
                              TEMP = ALPHA*B(K,J)
                              B(K,J) = TEMP
                              IF (NOUNIT) B(K,J) = B(K,J)*A(K,K)
                              DO 60 I = K + 1,M
                                  B(I,J) = B(I,J) + TEMP*A(I,K)
   60                         CONTINUE
                          END IF
   70                 CONTINUE
   80             CONTINUE
              END IF
          ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Form  B := alpha*A'*B   or   B := alpha*conjg( A' )*B.
</span><span class="comment">*</span><span class="comment">
</span>              IF (UPPER) THEN
                  DO 120 J = 1,N
                      DO 110 I = M,1,-1
                          TEMP = B(I,J)
                          IF (NOCONJ) THEN
                              IF (NOUNIT) TEMP = TEMP*A(I,I)
                              DO 90 K = 1,I - 1
                                  TEMP = TEMP + A(K,I)*B(K,J)
   90                         CONTINUE
                          ELSE
                              IF (NOUNIT) TEMP = TEMP*CONJG(A(I,I))
                              DO 100 K = 1,I - 1
                                  TEMP = TEMP + CONJG(A(K,I))*B(K,J)
  100                         CONTINUE
                          END IF
                          B(I,J) = ALPHA*TEMP
  110                 CONTINUE
  120             CONTINUE
              ELSE
                  DO 160 J = 1,N
                      DO 150 I = 1,M
                          TEMP = B(I,J)
                          IF (NOCONJ) THEN
                              IF (NOUNIT) TEMP = TEMP*A(I,I)
                              DO 130 K = I + 1,M
                                  TEMP = TEMP + A(K,I)*B(K,J)
  130                         CONTINUE
                          ELSE
                              IF (NOUNIT) TEMP = TEMP*CONJG(A(I,I))
                              DO 140 K = I + 1,M
                                  TEMP = TEMP + CONJG(A(K,I))*B(K,J)
  140                         CONTINUE
                          END IF
                          B(I,J) = ALPHA*TEMP
  150                 CONTINUE
  160             CONTINUE
              END IF
          END IF
      ELSE
          IF (<a name="LSAME.278"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(TRANSA,<span class="string">'N'</span>)) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Form  B := alpha*B*A.
</span><span class="comment">*</span><span class="comment">
</span>              IF (UPPER) THEN
                  DO 200 J = N,1,-1
                      TEMP = ALPHA
                      IF (NOUNIT) TEMP = TEMP*A(J,J)
                      DO 170 I = 1,M
                          B(I,J) = TEMP*B(I,J)
  170                 CONTINUE
                      DO 190 K = 1,J - 1
                          IF (A(K,J).NE.ZERO) THEN
                              TEMP = ALPHA*A(K,J)
                              DO 180 I = 1,M
                                  B(I,J) = B(I,J) + TEMP*B(I,K)
  180                         CONTINUE
                          END IF
  190                 CONTINUE
  200             CONTINUE
              ELSE
                  DO 240 J = 1,N
                      TEMP = ALPHA
                      IF (NOUNIT) TEMP = TEMP*A(J,J)
                      DO 210 I = 1,M
                          B(I,J) = TEMP*B(I,J)
  210                 CONTINUE
                      DO 230 K = J + 1,N
                          IF (A(K,J).NE.ZERO) THEN
                              TEMP = ALPHA*A(K,J)
                              DO 220 I = 1,M
                                  B(I,J) = B(I,J) + TEMP*B(I,K)
  220                         CONTINUE
                          END IF
  230                 CONTINUE
  240             CONTINUE
              END IF
          ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Form  B := alpha*B*A'   or   B := alpha*B*conjg( A' ).
</span><span class="comment">*</span><span class="comment">
</span>              IF (UPPER) THEN
                  DO 280 K = 1,N
                      DO 260 J = 1,K - 1
                          IF (A(J,K).NE.ZERO) THEN
                              IF (NOCONJ) THEN
                                  TEMP = ALPHA*A(J,K)
                              ELSE
                                  TEMP = ALPHA*CONJG(A(J,K))
                              END IF
                              DO 250 I = 1,M
                                  B(I,J) = B(I,J) + TEMP*B(I,K)
  250                         CONTINUE
                          END IF
  260                 CONTINUE
                      TEMP = ALPHA
                      IF (NOUNIT) THEN
                          IF (NOCONJ) THEN
                              TEMP = TEMP*A(K,K)
                          ELSE
                              TEMP = TEMP*CONJG(A(K,K))
                          END IF
                      END IF
                      IF (TEMP.NE.ONE) THEN
                          DO 270 I = 1,M
                              B(I,K) = TEMP*B(I,K)
  270                     CONTINUE
                      END IF
  280             CONTINUE
              ELSE
                  DO 320 K = N,1,-1
                      DO 300 J = K + 1,N
                          IF (A(J,K).NE.ZERO) THEN
                              IF (NOCONJ) THEN
                                  TEMP = ALPHA*A(J,K)
                              ELSE
                                  TEMP = ALPHA*CONJG(A(J,K))
                              END IF
                              DO 290 I = 1,M
                                  B(I,J) = B(I,J) + TEMP*B(I,K)
  290                         CONTINUE
                          END IF
  300                 CONTINUE
                      TEMP = ALPHA
                      IF (NOUNIT) THEN
                          IF (NOCONJ) THEN
                              TEMP = TEMP*A(K,K)
                          ELSE
                              TEMP = TEMP*CONJG(A(K,K))
                          END IF
                      END IF
                      IF (TEMP.NE.ONE) THEN
                          DO 310 I = 1,M
                              B(I,K) = TEMP*B(I,K)
  310                     CONTINUE
                      END IF
  320             CONTINUE
              END IF
          END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CTRMM.381"></a><a href="ctrmm.f.html#CTRMM.1">CTRMM</a> .
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
